<?php
// +----------------------------------------------------------------------
// | 模板管理
// +----------------------------------------------------------------------
// | @link ( http://www.yurnero.net )
// +----------------------------------------------------------------------
// | @copyright
// +----------------------------------------------------------------------
// | @licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | @author Haijun Wu <nicholasinlove@126.com>
// +----------------------------------------------------------------------
// | $Id: TemplateAction.class.php 55 2011-03-15 14:23:32Z nicholasinlove1986@gmail.com $
// +----------------------------------------------------------------------


class TemplateAction extends BaseAction {

	public function index() {
		redirect(__APP__);
	}
		
	public function pageStyle() {
		$path = ROOT_PATH.'Public/Css/pages.css';
		$content = str_replace("\xEF\xBB\xBF", '', @htmlspecialchars(file_get_contents($path)));
		$this->assign('ur_here',L('pageStyle'));
		$this->assign('content',$content);
		$this->display();
	}
	
	public function updatePageStyle() {
		$path = ROOT_PATH.'Public/Css/pages.css';
		//$content = stripslashes_deep(trim($_POST['pagestyle']));
		if (file_exists($path)) {
			//@file_put_contents($path,$content);
			//set_log('edit(Template, PageStyle)');
			$this->success('disabled');
		} else {
			$this->error(L('error'));
		}
	}
    
	public function listTemplate() {
	
		/* 获得当前的模版的信息 */
		$curr_template = C('tpl_name');
		/* 获得可用的模版 */
		$available_templates_list = array();
		$path =  TEMPLATE_DIR;
		/* 获得可用的模版 */
		$available_templates_list = array();
		$template_dir = @opendir($path);
		while ($file = readdir($template_dir)) {
			if ($file != '.' && $file != '..' && is_dir($path . $file) && $file != '.svn' && $file != 'index.htm' && $file != 'index.php' && $file != 'index.html') {
				$available_templates_list[] = get_template_info($file);
			}
		}
		@closedir($template_dir);
		
		$this->assign('ur_here',L('template'));
		$this->assign('curr_template',get_template_info($curr_template));
		$this->assign('available_templates_list', $available_templates_list);
		$this->display();
	}
	
}

?>